package thread;

/**
 * @author weim
 * @date 18-8-29
 */
public class MyJoin {

    public static void main(String[] args) {

        Thread thread = Thread.currentThread();

        for(int i=0; i<10; i++) {
            Thread t = new Thread(new One("thread name "+i, thread));
            thread = t;
            thread.start();
        }

        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("bbbbbbbbbbbbbbbbbbbbbbb");

    }
}

class One implements Runnable {

    private String name;
    private Thread thread;

    public One(String name, Thread thread) {
        this.name = name;
        this.thread = thread;
    }

    @Override
    public void run() {

        try {
            thread.join();
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println(name);
    }
}